package com.example.onlinemusic.tools;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class BcryptTest {
    public static void main(String[] args) {
        BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
        String password = "1234";
        // encode用来加密，每次加密出的密码都是随机的
        String encode = bCryptPasswordEncoder.encode(password);
        System.out.println("加密后的密码："+encode);
        // matches用来对比密码
        boolean result = bCryptPasswordEncoder.matches(password, encode);
        System.out.println(result);

        boolean result2 = bCryptPasswordEncoder.matches("12345", encode);
        System.out.println(result2);
    }
}
